Skip to content

Mega polls ESP32 for cached notifications on idle#15

Open
Recelis wants to merge 1 commit into
mainfrom
feature/mega-poll-on-idle
Open

Mega polls ESP32 for cached notifications on idle#15
Recelis wants to merge 1 commit into
mainfrom
feature/mega-poll-on-idle

Conversation

@Recelis

@Recelis Recelis commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

Replaces the 5-minute idle screen with an on-demand poll. When the idle timeout fires, the Mega sends a single 'P' byte to the ESP32 over Serial1. The ESP32 caches its last received MQTT batch and re-sends it — the display always shows real notifications.

Changes

  • ESP32 main.cpp: adds String lastBatch global, populated in messageHandler(). loop() checks Serial1.available() for 'P' and re-sends lastBatch when received.
  • Mega Communication: adds sendPollRequest() — writes 'P' to Serial1
  • Mega LCD: checkIdle() now returns bool, fires true only once per idle cycle (not every 100ms loop). Removed drawIdleScreen() entirely.
  • Mega main.cpp: calls sendPollRequest() when checkIdle() returns true

Memory

String lastBatch on ESP32 holds up to ~6KB. ESP32 has 177KB free heap — negligible cost.

Test plan

  • Flash both boards
  • Trigger POST /weather/fetch — weather row appears on TFT
  • Wait 5+ minutes — display stays showing weather (no idle screen, poll fires instead)
  • Serial log on ESP32 shows "Poll request received — re-sending last batch"
  • Trigger another push — display updates normally

🤖 Generated with Claude Code

When the 5-minute idle timeout fires, the Mega sends a single 'P' byte
to the ESP32 over Serial1 instead of clearing the display. The ESP32
caches the last received MQTT batch and re-sends it on demand, so the
display always shows the most recent notifications.

Memory cost on ESP32: one String (~6KB max) against 177KB free heap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant